<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>厕所门把手 | 美的楼宇科技研究院</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="iBUILDING作为智慧建筑的数字践行者，致力于用数字的眼光建筑世界。以科技赋能楼宇，构建数字建筑生态，共创更美好的智慧空间。Make iBUILDING come TRUE。">
    <meta name="keywords" content="iBUILDING,ibuilding">
    <meta name="theme-color" content="#11a8cd">
    <meta name="baidu-site-verification" content="code-j1XZ46JIBR">
    
    <link rel="preload" href="/assets/css/0.styles.af9b49f9.css" as="style"><link rel="preload" href="/assets/js/app.ffe9b366.js" as="script"><link rel="preload" href="/assets/js/2.9760a328.js" as="script"><link rel="preload" href="/assets/js/3.0b2e2ac4.js" as="script"><link rel="prefetch" href="/assets/js/10.1ca8e9a5.js"><link rel="prefetch" href="/assets/js/11.f84ca260.js"><link rel="prefetch" href="/assets/js/12.5d62fb57.js"><link rel="prefetch" href="/assets/js/13.3fd35f26.js"><link rel="prefetch" href="/assets/js/14.d428d44b.js"><link rel="prefetch" href="/assets/js/15.752b1e82.js"><link rel="prefetch" href="/assets/js/16.f33da816.js"><link rel="prefetch" href="/assets/js/17.4a25f92e.js"><link rel="prefetch" href="/assets/js/18.3ad538ff.js"><link rel="prefetch" href="/assets/js/19.4957cef9.js"><link rel="prefetch" href="/assets/js/20.264d8716.js"><link rel="prefetch" href="/assets/js/21.2e6c7b77.js"><link rel="prefetch" href="/assets/js/22.4abc22b5.js"><link rel="prefetch" href="/assets/js/23.52e85444.js"><link rel="prefetch" href="/assets/js/24.ae24e643.js"><link rel="prefetch" href="/assets/js/25.5596a9ad.js"><link rel="prefetch" href="/assets/js/26.d952969d.js"><link rel="prefetch" href="/assets/js/27.7711bd91.js"><link rel="prefetch" href="/assets/js/4.d41f70ee.js"><link rel="prefetch" href="/assets/js/5.603be3f5.js"><link rel="prefetch" href="/assets/js/6.36f53e66.js"><link rel="prefetch" href="/assets/js/7.8566b5df.js"><link rel="prefetch" href="/assets/js/8.82830ba8.js"><link rel="prefetch" href="/assets/js/9.d949e13c.js">
    <link rel="stylesheet" href="/assets/css/0.styles.af9b49f9.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://static-btri.midea.com/mfs/1001/1656483801940.svg" alt="美的楼宇科技研究院" class="logo"> <span class="site-name can-hide">美的楼宇科技研究院</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="📖开源项目" class="dropdown-title"><!----> <span class="title" style="display:;">📖开源项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/driver-box/" class="nav-link">driver-box</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发者社区" class="dropdown-title"><!----> <span class="title" style="display:;">开发者社区</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/about.html" class="nav-link">技术博客</a></li><li class="dropdown-item"><!----> <a href="https://openibuilding.midea.com/home" target="_blank" rel="noopener noreferrer" class="nav-link external">
  开放平台
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开源仓库" class="dropdown-title"><!----> <span class="title" style="display:;">开源仓库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/iBUILDING-X" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="📖开源项目" class="dropdown-title"><!----> <span class="title" style="display:;">📖开源项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/driver-box/" class="nav-link">driver-box</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发者社区" class="dropdown-title"><!----> <span class="title" style="display:;">开发者社区</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/about.html" class="nav-link">技术博客</a></li><li class="dropdown-item"><!----> <a href="https://openibuilding.midea.com/home" target="_blank" rel="noopener noreferrer" class="nav-link external">
  开放平台
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开源仓库" class="dropdown-title"><!----> <span class="title" style="display:;">开源仓库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/iBUILDING-X" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/driver-box/" class="sidebar-link">driver-box</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>用户手册</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/driver-box/quick_start/" class="sidebar-link">快速开始</a></li><li><a href="/driver-box/guides/config/" class="sidebar-link">配置说明</a></li><li><a href="/pages/8e66ec/" class="sidebar-link">HTTP Client 插件</a></li><li><a href="/pages/3162cd/" class="sidebar-link">HTTP Server 插件</a></li><li><a href="/pages/f8d682/" class="sidebar-link">Modbus 插件</a></li><li><a href="/pages/4fcadc/" class="sidebar-link">BACnet 插件</a></li><li><a href="/pages/417ad9/" class="sidebar-link">MQTT 插件</a></li><li><a href="/pages/312d09/" class="sidebar-link">TCP Server 插件</a></li><li><a href="/pages/28a924/" class="sidebar-link">脚本内置模块</a></li><li><a href="/pages/da9d86/" class="sidebar-link">RESTful API</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>开发者手册</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/driver-box/dev/compile_run/" class="sidebar-link">编译运行</a></li><li><a href="/driver-box/dev/release/" class="sidebar-link">发版记录</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>设计思路</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/design/concept/" class="sidebar-link">相关概念</a></li><li><a href="/pages/design/structure/" class="sidebar-link">系统架构</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>设备实战</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/674f6d/" aria-current="page" class="active sidebar-link">厕所门把手</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>driver-box</span></li><li data-v-06225672><span data-v-06225672>设备实战</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="javascript:;" data-v-06225672>爱丁</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-07-31</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><!----> <h1><img src="">厕所门把手<!----></h1> <div class="page-slot page-slot-top">
    <div class="wwads-cn wwads-horizontal page-wwads" data-id="136"></div>
    <style>
      .page-wwads{
        width:100%!important;
        min-height: 0;
        margin: 0;
      }
      .page-wwads .wwads-img img{
        width:80px!important;
      }
      .page-wwads .wwads-poweredby{
        width: 40px;
        position: absolute;
        right: 25px;
        bottom: 3px;
      }
      .wwads-content .wwads-text, .page-wwads .wwads-text{
        height: 100%;
        padding-top: 5px;
        display: block;
      }
  </style>
  </div> <div class="theme-vdoing-content content__default"><p><strong>工作流程</strong>：</p> <p><img src="/assets/img/1.1ef1b0d9.svg" alt=""></p> <ol><li>门把手通过内置的自发电模块，通过无线发射信号将开关状态传输至设备网关。</li> <li>设备网关通过 http 协议周期性上报设备状态至 driver-box。</li> <li>driver-box 提取设备网关中的点位数据，封装成标准物模型结构报文发送至 mqtt broker。</li> <li>云端或边缘服务节点以 mqtt client 角色接受 broker 投递过来的设备数据。</li></ol> <p><strong>准备工作</strong>：</p> <ol><li><p>一台作为 driver-box 边缘网关的服务器：PC、笔记本、树莓派皆可，假定其 IP 为：<code>192.168.16.35</code></p></li> <li><p>安装设备使用手册完成配网设置。</p> <img src="/assets/img/step_1.fc16b14b.png" width="50%"></li></ol> <p>完成准备工作后，设备网关会周期性地往 driver-box 边缘网关：192.168.16.35 的 59997 端口发送包含设备数据的 http 报文。</p> <details class="custom-block details"><summary>点击查看</summary> <div class="language-json line-numbers-mode"><pre class="language-json"><code><span class="token punctuation">{</span>
    <span class="token property">&quot;ID&quot;</span><span class="token operator">:</span><span class="token string">&quot;3473784049707005764&quot;</span><span class="token punctuation">,</span> <span class="token comment">//设备网关编号</span>
    <span class="token property">&quot;A1&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A2&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A3&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A4&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A5&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
            <span class="token property">&quot;Add&quot;</span><span class="token operator">:</span><span class="token string">&quot;225cfb&quot;</span><span class="token punctuation">,</span> <span class="token comment">//门把手编号</span>
            <span class="token property">&quot;Sta&quot;</span><span class="token operator">:</span><span class="token number">0</span> <span class="token comment">//开关状态</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A6&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A7&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A8&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;A9&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;AA&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">&quot;AB&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>

    <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br></div></div></details> <p><strong>网关接入</strong></p> <ol><li><p>下载最新版 <a href="https://gitee.com/ibuildingX/driver-box/releases" target="_blank" rel="noopener noreferrer">driver-box<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 并部署至边缘网关。</p></li> <li><p>在 driver-box 同路径下创建 <code>driver-config/&lt;自定义子目录&gt;</code> 目录，例如：<code>driver-config/switch</code>。</p></li> <li><p>将以下设备接入描述文件放置在<code>driver-config/&lt;自定义子目录&gt;</code>下。</p> <details class="custom-block details"><summary>点击查看</summary> <div class="theme-code-group" data-v-2f5f1757><div class="theme-code-group__nav" data-v-2f5f1757><ul class="theme-code-group__ul" data-v-2f5f1757></ul></div> <div class="theme-code-block theme-code-block__active" data-v-4f1e9d0c><div class="language-json line-numbers-mode" data-v-4f1e9d0c><pre class="language-json" data-v-4f1e9d0c><code data-v-4f1e9d0c><span class="token punctuation" data-v-4f1e9d0c>{</span>
    <span class="token property" data-v-4f1e9d0c>&quot;deviceModels&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token punctuation" data-v-4f1e9d0c>[</span>
        <span class="token punctuation" data-v-4f1e9d0c>{</span>
            <span class="token property" data-v-4f1e9d0c>&quot;name&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;switch-http-Device-Profile&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
            <span class="token property" data-v-4f1e9d0c>&quot;modelId&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span> <span class="token string" data-v-4f1e9d0c>&quot;door.switch&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
            <span class="token property" data-v-4f1e9d0c>&quot;description&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;厕所门把手模型&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
            <span class="token property" data-v-4f1e9d0c>&quot;devicePoints&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token punctuation" data-v-4f1e9d0c>[</span>
                <span class="token punctuation" data-v-4f1e9d0c>{</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;name&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;onOff&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;description&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;开关（0未使用，1使用中）&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;valueType&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;int&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;readWrite&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;R&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;reportMode&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;change&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;timerReport&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;15m&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;realReport&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token boolean" data-v-4f1e9d0c>true</span>
                <span class="token punctuation" data-v-4f1e9d0c>}</span>
            <span class="token punctuation" data-v-4f1e9d0c>]</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
            <span class="token property" data-v-4f1e9d0c>&quot;devices&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span> <span class="token punctuation" data-v-4f1e9d0c>[</span>
                <span class="token punctuation" data-v-4f1e9d0c>{</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;name&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;3473784049707005764_225cfb&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;description&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;厕所门把手&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;connectionKey&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;common&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
                    <span class="token property" data-v-4f1e9d0c>&quot;protocol&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token punctuation" data-v-4f1e9d0c>{</span><span class="token punctuation" data-v-4f1e9d0c>}</span>
                <span class="token punctuation" data-v-4f1e9d0c>}</span>
            <span class="token punctuation" data-v-4f1e9d0c>]</span>
        <span class="token punctuation" data-v-4f1e9d0c>}</span>
    <span class="token punctuation" data-v-4f1e9d0c>]</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
    <span class="token property" data-v-4f1e9d0c>&quot;connections&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token punctuation" data-v-4f1e9d0c>{</span>
        <span class="token property" data-v-4f1e9d0c>&quot;common&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token punctuation" data-v-4f1e9d0c>{</span>
            <span class="token property" data-v-4f1e9d0c>&quot;host&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span> <span class="token string" data-v-4f1e9d0c>&quot;0.0.0.0&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
            <span class="token property" data-v-4f1e9d0c>&quot;port&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span> <span class="token number" data-v-4f1e9d0c>59997</span>
        <span class="token punctuation" data-v-4f1e9d0c>}</span>
    <span class="token punctuation" data-v-4f1e9d0c>}</span><span class="token punctuation" data-v-4f1e9d0c>,</span>
    <span class="token property" data-v-4f1e9d0c>&quot;protocolName&quot;</span><span class="token operator" data-v-4f1e9d0c>:</span><span class="token string" data-v-4f1e9d0c>&quot;http_server&quot;</span>
<span class="token punctuation" data-v-4f1e9d0c>}</span>
</code></pre> <div class="line-numbers-wrapper" data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>1</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>2</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>3</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>4</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>5</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>6</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>7</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>8</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>9</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>10</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>11</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>12</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>13</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>14</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>15</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>16</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>17</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>18</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>19</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>20</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>21</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>22</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>23</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>24</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>25</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>26</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>27</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>28</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>29</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>30</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>31</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>32</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>33</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>34</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>35</span><br data-v-4f1e9d0c></div></div></div> <div class="theme-code-block" data-v-4f1e9d0c><div class="language-lua line-numbers-mode" data-v-4f1e9d0c><pre class="language-lua" data-v-4f1e9d0c><code data-v-4f1e9d0c><span class="token keyword" data-v-4f1e9d0c>local</span> json <span class="token operator" data-v-4f1e9d0c>=</span> <span class="token function" data-v-4f1e9d0c>require</span><span class="token punctuation" data-v-4f1e9d0c>(</span><span class="token string" data-v-4f1e9d0c>&quot;json&quot;</span><span class="token punctuation" data-v-4f1e9d0c>)</span>

<span class="token comment" data-v-4f1e9d0c>-- decode 请求数据解码</span>
<span class="token keyword" data-v-4f1e9d0c>function</span> <span class="token function" data-v-4f1e9d0c>decode</span><span class="token punctuation" data-v-4f1e9d0c>(</span>raw<span class="token punctuation" data-v-4f1e9d0c>)</span>
   <span class="token keyword" data-v-4f1e9d0c>local</span> data <span class="token operator" data-v-4f1e9d0c>=</span> json<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>decode</span><span class="token punctuation" data-v-4f1e9d0c>(</span>raw<span class="token punctuation" data-v-4f1e9d0c>)</span>
   <span class="token comment" data-v-4f1e9d0c>-- 路径及方法判断</span>
   <span class="token keyword" data-v-4f1e9d0c>if</span> data<span class="token punctuation" data-v-4f1e9d0c>.</span>path <span class="token operator" data-v-4f1e9d0c>~=</span> <span class="token string" data-v-4f1e9d0c>&quot;/report&quot;</span> <span class="token keyword" data-v-4f1e9d0c>or</span> data<span class="token punctuation" data-v-4f1e9d0c>.</span>method <span class="token operator" data-v-4f1e9d0c>~=</span> <span class="token string" data-v-4f1e9d0c>&quot;POST&quot;</span> <span class="token keyword" data-v-4f1e9d0c>then</span>
      <span class="token keyword" data-v-4f1e9d0c>return</span> <span class="token string" data-v-4f1e9d0c>&quot;[]&quot;</span>
   <span class="token keyword" data-v-4f1e9d0c>end</span>
   <span class="token comment" data-v-4f1e9d0c>-- 解析 body</span>
   <span class="token keyword" data-v-4f1e9d0c>local</span> body <span class="token operator" data-v-4f1e9d0c>=</span> json<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>decode</span><span class="token punctuation" data-v-4f1e9d0c>(</span>data<span class="token punctuation" data-v-4f1e9d0c>.</span>body<span class="token punctuation" data-v-4f1e9d0c>)</span>
   <span class="token comment" data-v-4f1e9d0c>-- 解析网关及设备数据</span>
   <span class="token keyword" data-v-4f1e9d0c>local</span> gateWay <span class="token operator" data-v-4f1e9d0c>=</span> body<span class="token punctuation" data-v-4f1e9d0c>.</span>ID
   <span class="token keyword" data-v-4f1e9d0c>local</span> list <span class="token operator" data-v-4f1e9d0c>=</span> body<span class="token punctuation" data-v-4f1e9d0c>.</span>A5
   <span class="token comment" data-v-4f1e9d0c>-- 循环设备列表</span>
   <span class="token keyword" data-v-4f1e9d0c>local</span> devices <span class="token operator" data-v-4f1e9d0c>=</span> <span class="token punctuation" data-v-4f1e9d0c>{</span><span class="token punctuation" data-v-4f1e9d0c>}</span>
   <span class="token keyword" data-v-4f1e9d0c>for</span> i<span class="token punctuation" data-v-4f1e9d0c>,</span> v <span class="token keyword" data-v-4f1e9d0c>in</span> <span class="token function" data-v-4f1e9d0c>ipairs</span><span class="token punctuation" data-v-4f1e9d0c>(</span>list<span class="token punctuation" data-v-4f1e9d0c>)</span> <span class="token keyword" data-v-4f1e9d0c>do</span>
      <span class="token keyword" data-v-4f1e9d0c>local</span> device<span class="token punctuation" data-v-4f1e9d0c>,</span> values<span class="token punctuation" data-v-4f1e9d0c>,</span> value <span class="token operator" data-v-4f1e9d0c>=</span> <span class="token punctuation" data-v-4f1e9d0c>{</span><span class="token punctuation" data-v-4f1e9d0c>}</span><span class="token punctuation" data-v-4f1e9d0c>,</span> <span class="token punctuation" data-v-4f1e9d0c>{</span><span class="token punctuation" data-v-4f1e9d0c>}</span><span class="token punctuation" data-v-4f1e9d0c>,</span> <span class="token punctuation" data-v-4f1e9d0c>{</span><span class="token punctuation" data-v-4f1e9d0c>}</span>
      <span class="token keyword" data-v-4f1e9d0c>if</span> v<span class="token punctuation" data-v-4f1e9d0c>.</span>Add <span class="token operator" data-v-4f1e9d0c>~=</span> <span class="token string" data-v-4f1e9d0c>&quot;&quot;</span> <span class="token keyword" data-v-4f1e9d0c>then</span>
         <span class="token comment" data-v-4f1e9d0c>-- deviceSN</span>
         device<span class="token punctuation" data-v-4f1e9d0c>.</span>device_name <span class="token operator" data-v-4f1e9d0c>=</span> string<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>format</span><span class="token punctuation" data-v-4f1e9d0c>(</span><span class="token string" data-v-4f1e9d0c>&quot;%s_%s&quot;</span><span class="token punctuation" data-v-4f1e9d0c>,</span> gateWay<span class="token punctuation" data-v-4f1e9d0c>,</span> v<span class="token punctuation" data-v-4f1e9d0c>.</span>Add<span class="token punctuation" data-v-4f1e9d0c>)</span>
         <span class="token comment" data-v-4f1e9d0c>-- device points</span>
         value<span class="token punctuation" data-v-4f1e9d0c>.</span>name <span class="token operator" data-v-4f1e9d0c>=</span> <span class="token string" data-v-4f1e9d0c>&quot;onOff&quot;</span>
         value<span class="token punctuation" data-v-4f1e9d0c>.</span>value <span class="token operator" data-v-4f1e9d0c>=</span> <span class="token function" data-v-4f1e9d0c>tonumber</span><span class="token punctuation" data-v-4f1e9d0c>(</span>v<span class="token punctuation" data-v-4f1e9d0c>.</span>Sta<span class="token punctuation" data-v-4f1e9d0c>)</span>
         table<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>insert</span><span class="token punctuation" data-v-4f1e9d0c>(</span>values<span class="token punctuation" data-v-4f1e9d0c>,</span> value<span class="token punctuation" data-v-4f1e9d0c>)</span>
         device<span class="token punctuation" data-v-4f1e9d0c>.</span>values <span class="token operator" data-v-4f1e9d0c>=</span> values
         table<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>insert</span><span class="token punctuation" data-v-4f1e9d0c>(</span>devices<span class="token punctuation" data-v-4f1e9d0c>,</span> device<span class="token punctuation" data-v-4f1e9d0c>)</span>
      <span class="token keyword" data-v-4f1e9d0c>end</span>
   <span class="token keyword" data-v-4f1e9d0c>end</span>
   <span class="token comment" data-v-4f1e9d0c>-- 返回设备数据</span>
   <span class="token keyword" data-v-4f1e9d0c>return</span> json<span class="token punctuation" data-v-4f1e9d0c>.</span><span class="token function" data-v-4f1e9d0c>encode</span><span class="token punctuation" data-v-4f1e9d0c>(</span>devices<span class="token punctuation" data-v-4f1e9d0c>)</span>
<span class="token keyword" data-v-4f1e9d0c>end</span>
</code></pre> <div class="line-numbers-wrapper" data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>1</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>2</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>3</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>4</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>5</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>6</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>7</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>8</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>9</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>10</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>11</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>12</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>13</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>14</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>15</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>16</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>17</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>18</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>19</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>20</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>21</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>22</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>23</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>24</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>25</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>26</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>27</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>28</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>29</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>30</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>31</span><br data-v-4f1e9d0c><span class="line-number" data-v-4f1e9d0c>32</span><br data-v-4f1e9d0c></div></div></div> <pre class="pre-blank" data-v-2f5f1757>// Make sure to add code blocks to your code group</pre></div></details></li> <li><p>启动 driver-box 服务</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>./driver-box <span class="token parameter variable">-broker</span><span class="token operator">=</span>mqtt://<span class="token operator">&lt;</span>ip<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>port<span class="token operator">&gt;</span> <span class="token punctuation">\</span>
  <span class="token parameter variable">-clientId</span><span class="token operator">=</span><span class="token operator">&lt;</span>clientId<span class="token operator">&gt;</span> <span class="token punctuation">\</span>
  <span class="token parameter variable">-username</span><span class="token operator">=</span><span class="token operator">&lt;</span>username<span class="token operator">&gt;</span> <span class="token punctuation">\</span>
  <span class="token parameter variable">-password</span><span class="token operator">=</span><span class="token operator">&lt;</span>password<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>启动 mqtt client 订阅 broker，并拨动门把手开关。<br>
结果如下图，driver-box每隔一秒钟接收到设备网关上报的报文；driver-box 将设备点位的变化量上报至 mqtt broker。
<img src="/assets/img/demo.0d38084e.png" alt=""></p></li></ol></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/08/01, 09:58:26</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/design/structure/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">系统架构</div></a> <!----></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/design/structure/" class="prev">系统架构</a></span> <!----></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="https://gitee.com/iBUILDING-X" title="Gitee" target="_blank" class="iconfont icon-gitee"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2023
    <span>iBUILDING</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.ffe9b366.js" defer></script><script src="/assets/js/2.9760a328.js" defer></script><script src="/assets/js/3.0b2e2ac4.js" defer></script>
  </body>
</html>
